﻿using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Logging;
using Microsoft.Practices.EnterpriseLibrary.Common;
using PMS.ENT;
using System.IO;
using System.Configuration;

namespace PMS.DAL
{
    public class LogDAL
    {


        #region Insert methods
        public void Log(LogENT log)
        {
            try
            {
                Logger.Write(log);
            }

            catch (Exception ex)
            {
                throw ex;
            }
        }

        #endregion
    
        public static void LogEx(string ExCode,Exception ex)
        {
            string FileName = System.AppDomain.CurrentDomain.BaseDirectory + ConfigurationSettings.AppSettings["LogFile"];
            StreamWriter f = File.AppendText(FileName);
            string Str = "----------------header------------------------\r\n";
            Str = Str + "Timestamp: " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString();
            Str = Str + "\r\nExceptionCode: " + ExCode;
            Str = Str + "\r\nMessage: " + ex.Message;
            Str = Str + "\r\nStackTrace:\r\n" + ex.StackTrace;
            Str = Str + "\r\nSource: " + ex.Source;
            Str = Str + "\r\n\r\n";
            
            f.Write(Str);
            f.Close(); 

        }
    }
}
